import 'package:flutter/material.dart';
import 'package:flutter_app/pages/News.dart';

import '../pages/tabs/Tabs.dart';
import '../pages/Form.dart';
import '../pages/Search.dart';

import '../pages/user/Login.dart';
import '../pages/user/RegisterFirst.dart';
import '../pages/user/RegisterSecond.dart';
import '../pages/user/RegisterThird.dart';
import '../pages/AppBarDemo.dart';
import '../pages/Buttons.dart';
import '../pages/Field.dart';
import '../pages/CheckBox.dart';
import '../pages/DatePicker.dart';
import '../pages/Swiper.dart';
import '../pages/Function.dart';
import '../pages/News.dart';
import '../pages/ThirdDatePicker.dart';
import '../pages/News.dart';
import '../pages/NewsContent.dart';

final routes = {
  '/': (context, {arguments}) => Tabs(),
  '/form': (context, {arguments}) => FormPage(),
  '/search': (context, {arguments}) => SearchPage(arguments: arguments),
  '/login': (context) => LoginPage(),
  '/registerFirst': (context) => RegisterFirstPage(),
  '/registerSecond': (context) => RegisterSecondPage(),
  '/registerThird': (context) => RegisterThirdPage(),
  '/appBarDemo': (context) => AppBarDemoPage(),
  '/buttons': (context) => ButtonsPage(),
  '/field': (context) => FieldPage(),
  '/checkbox': (context) => CheckBoxDemo(),
  '/datepicker': (context) => DatePickerDemo(),
  '/thirddatepicker': (context) => ThirdDatePickerDemo(),
  '/news': (context) => NewsDemo(),
  '/newscontent': (context, {arguments}) => NewsContentPage(arguments: arguments),
  '/swiper': (context) => SwiperDemo(),
  '/function': (context) => FunctionDemo(),
  '/news': (context) => NewsDemo(),
  '/thirddatepicker': (context) => ThirdDatePickerDemo()
};

var onGenerateRoute = (RouteSettings settings) {
  final String name = settings.name;
  final Function pageContentBuilder = routes[name];

  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(builder: (context) => pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route = MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
